package CI.aufgabe2.cip.mynodes;

import java.util.List;

import CI.aufgabe2.cip.SymbolTable;
import CI.aufgabe2.cip.base.AbstractDescr;
import CI.aufgabe2.cip.descriptor.RecordDescr;

public class MyRecordTypeNode extends MyAbstractNode {

	private static final long serialVersionUID = 1L;

	private final List<MyFieldListNode> fieldListList;

	public MyRecordTypeNode(List<MyFieldListNode> fieldList) {
		this.fieldListList = fieldList;
	}

	@Override
	public void print() {
		trace("RecordTypeNode ");
		if (fieldListList != null)
			for (MyFieldListNode fieldList : fieldListList) {
				if (fieldList != null)
					fieldList.print();
			}
		unindent();

	}
	
	public AbstractDescr compile(SymbolTable sym) {
		SymbolTable symbolTable = new SymbolTable(sym); //neue Symboltabelle
    	for(MyAbstractNode node : fieldListList){
    		node.compile(symbolTable);		//schreibe Variablen in neue Symboltabelle
    	}
    	return new RecordDescr(symbolTable); 
	}
}
